function line(){
    var options = {
        backgroundColor: "#ffffff",
        lineWidth: 1,
        dotRadius: 3,
        dotType: "disc",
        hLineWidth: 2,
        hLineType: "dotted",
        hLineColor: "#aaaaaa",
        label: {
            enable: true,
            Color: "#000000",
            FontSize: "10px",
            FontFamily: "Arial,sans-serif",
        },
        legend: {
            enable: true,
            FontSize: "12px",
            FontFamily: "Arial,sans-serif",
            Color: "#000000"
        },
        axisX: {
            lineWidth: 2,
            color: "#000000",
            caption: {
                Color: "#000000",
                FontSize: "12px",
                FontFamily: "Arial,sans-serif",
            },
            scale: {
                Color: "#000000",
                FontSize: "10px",
                FontFamily: "Arial,sans-serif"
            }
        },
        axisY: {
            Max: null,
            Min: 0,
            lineWidth: 2,
            color: "#000000",
            caption: {
                Color: "#000000",
                FontSize: "12px",
                FontFamily: "Arial,sans-serif",
            },
            scale: {
                Color: "#000000",
                FontSize: "10px",
                FontFamily: "Arial,sans-serif"
            }
        },
        grid: {
            backgroundColor: "#dddddd",
            gradation: true
        }
    }
    
    //绘图容器
    var canvas = null;
    //绘图内容
    var ctx = null;
    
    return {
        draw: function(opts){
            if (!opts || typeof(opts) != 'object') {
                throw new Error('参数为空或类型不正确！');
            }
            //添加或更新设置
            for (var option in opts) {
                options[option] = opts[option];
            }
            
            canvas = document.getElementById(options.canvasId);
            if (!canvas) {
                return;
            }
            if (canvas.nodeName != "CANVAS") {
                return;
            }
            if (canvas.parentNode.nodeName != "DIV") {
                return;
            };
            if (!canvas.getContext) {
                return;
            }
            ctx = canvas.getContext('2d');
            canvas.style.margin = "0";
            canvas.parentNode.style.position = "relative";
            canvas.parentNode.style.padding = "0";
            
            if (params.backgroundColor) {
                ctx.beginPath();
                ctx.fillStyle = params.backgroundColor;
                ctx.fillRect(0, 0, canvas.width, canvas.height);
            }
            if (canvas.width / canvas.height < 1.5 || canvas.height < 200) {
                params.legend == false;
            }
            //var canvas_pos = this._getElementAbsPos(this.canvas);
            var cpos = {
                x0: canvas.width * 0.1,
                y0: canvas.height * 0.9,
                x1: canvas.width * 0.9,
                y1: canvas.height * 0.1
            };
        },
        data: function(data){
            return options.data;
        },
        drawDashedLine: function(context, fromX, fromY, toX, toY, dashs){
            context.beginPath();
            var dx = toX - fromX;
            var dy = toY - fromY;
            var angle = Math.atan2(dy, dx);
            var x = fromX;
            var y = fromY;
            context.moveTo(fromX, fromY);
            var idx = 0;
            var draw = true;
            while (!((dx < 0 ? x <= toX : x >= toX) && (dy < 0 ? y <= toY : y >= toY))) {
                var dashLength = dashs[idx++ % dashs.length];
                var nx = x + (Math.cos(angle) * dashLength);
                x = dx < 0 ? Math.max(toX, nx) : Math.min(toX, nx);
                var ny = y + (Math.sin(angle) * dashLength);
                y = dy < 0 ? Math.max(toY, ny) : Math.min(toY, ny);
                if (draw) {
                    context.lineTo(x, y);
                }
                else {
                    context.moveTo(x, y);
                }
                draw = !draw;
            }
            
            context.closePath();
            context.stroke();
        }
    }
};
